package com.ltwc.lttv.api

import android.app.Activity
import android.content.Context
import android.content.Context.MODE_PRIVATE
import android.util.Log
import com.ltwc.lttv.Encryptor
import com.ltwc.lttv.tools.GetDeviceId.getMD5
import com.ltwc.lttv.tools.SP
import okhttp3.Interceptor
import okhttp3.Request
import okhttp3.Response

/**
 * Description：
 * Created on 2024/2/4 14:34
 * Organization:华云
 * author：AHuangSHang
 **/
class LTInterceptor() : Interceptor {
    override fun intercept(chain: Interceptor.Chain): Response {
        val request = chain.request()
        val builder = request.newBuilder()
        builder.addHeader(
            "Mac",
            buildMacAddress()
        )
        return chain.proceed(builder.build())
    }

    fun buildMacAddress(): String {
        var mac = SP.deviceId
        mac += "LTTV" + System.currentTimeMillis().toString()
        mac = Encrypt.aesEncrypt(mac)
        return mac;
    }
}